package edu.njust.controller;

import edu.njust.pojo.Message;
import edu.njust.service.ComputerService;
import edu.njust.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/MessageController")
public class MessageController {

    @Autowired
    @Qualifier("MessageServiceImpl")
    private MessageService messageService;

    //发送信息
    @RequestMapping("/sendMessage")
    public void sendMessage(Map<String, Object> map) {
        String send_id = String.valueOf(map.get("send_id"));
        List<String> receive_id = (List<String>)map.get("receive_id");
        String context = String.valueOf(map.get("context"));
        messageService.sendMessage(send_id, receive_id, context);
    }

    //显示接收的信息
    @RequestMapping("/showMessages")
    public List<Message> showReceiveMessage(@RequestParam("receiver_id") String receiver_id){
        return messageService.showAllMessage(receiver_id);
    }
}
